/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ProductDeleteView.java
 *
 * Created on 13/10/2009, 9:13:42 PM
 */

package javaclientcp3110.View.Product;

import common.Objects.Product;
import javaclientcp3110.Model.Product.ProductDeleteModel;
import common.UCM.UC2AL;
import javaclientcp3110.UCM.UCDeleteProduct;
import javax.swing.JOptionPane;

/**
 *
 * @author Slasher
 */
public class ProductDeleteView extends javax.swing.JPanel {
    private ProductDeleteModel model;
    /** Creates new form ProductDeleteView */
    public ProductDeleteView() {
        this(new ProductDeleteModel());
    }

    public ProductDeleteView(ProductDeleteModel model) {
        this.model = model;
        initComponents();
        updateProductList();
        prodDeleteButton.addActionListener(new UC2AL(new UCDeleteProduct(this, model)));
    }
    public Product getProduct() {
        return (Product) productListView.getSelectedItem();
    }
    public void updateProductList() {
        productListView.updateProductView();
    }
    public void errorMessage(String message) {
        JOptionPane.showMessageDialog(null,
            message,
            "Error",
            JOptionPane.ERROR_MESSAGE);
    }
    public void successMessage(String message) {
        JOptionPane.showMessageDialog(null,
            message,
            "Success!",
            JOptionPane.INFORMATION_MESSAGE);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        productListView = new javaclientcp3110.View.Product.ProductListView();
        titleLabel = new javax.swing.JLabel();
        prodDeleteButton = new javax.swing.JButton();

        productListView.setMaximumSize(new java.awt.Dimension(28, 20));

        titleLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        titleLabel.setText("Select a product to delete");

        prodDeleteButton.setText("Delete Product");
        prodDeleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prodDeleteButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(117, 117, 117)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(prodDeleteButton)
                    .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(productListView, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(126, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(titleLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(productListView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(prodDeleteButton)
                .addContainerGap(138, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void prodDeleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodDeleteButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_prodDeleteButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton prodDeleteButton;
    private javaclientcp3110.View.Product.ProductListView productListView;
    private javax.swing.JLabel titleLabel;
    // End of variables declaration//GEN-END:variables

}
